import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    shareUrl: '',
    token: localStorage.getItem('token') ? localStorage.getItem('token') : '',
    openId: localStorage.getItem('openId') ? localStorage.getItem('openId') : '',
    userInfo: {},
    bussinessTypeList: [
      { text: '全部', id: 0 },
      { text: '采购', id: 1 },
      { text: '供应', id: 2 },
      { text: '商务合作', id: 3 },
      { text: '招商引资', id: 4 },
      { text: '招聘', id: 5 }
    ],
    dutyList: [
      { type: 1, text: '法人' },
      { type: 2, text: '财务' },
      { type: 3, text: '销售' }
    ],
    tabList: [
      {
        text: '服务',
        icon: require('@assets/images/tabbar_icon_service.png'),
        iconSelected: require('@assets/images/tabbar_icon_service_selected.png'),
        path: '/service'
      },
      {
        text: '商机',
        icon: require('@assets/images/tabbar_icon_bussiness.png'),
        iconSelected: require('@assets/images/tabbar_icon_bussiness_selected.png'),
        path: '/bussiness'
      },
      {
        text: '礼包',
        icon: require('@assets/images/tabbar_icon_gift.png'),
        iconSelected: require('@assets/images/tabbar_icon_gift_selected.png'),
        path: '/gift'
      },
      {
        text: '我的',
        icon: require('@assets/images/tabbar_icon_mine.png'),
        iconSelected: require('@assets/images/tabbar_icon_mine_selected.png'),
        path: '/mine'
      }
    ]
  },
  mutations: {
    setOpenid(state, payload) {
      state.openId = payload;
    },
    setToken(state, payload) {
      state.token = payload;
    },
    setUserInfo(state, payload) {
      state.userInfo = payload;
    },
    setShareUrl(state, payload) {
      state.shareUrl = payload;
    }
  },
  actions: {},
  getters: {
    dutyList(state) {
      return state.dutyList;
    },
    tabList(state) {
      return state.tabList;
    },
    openId(state) {
      return state.openId;
    },
    token(state) {
      return state.token;
    },
    userInfo(state) {
      return state.userInfo;
    },
    bussinessTypeList(state) {
      return state.bussinessTypeList;
    }
  },
  modules: {}
});
